package com.inji.flink;

import java.util.UUID;

import org.apache.flink.api.common.JobExecutionResult;
import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.api.java.DataSet;
import org.apache.flink.api.java.ExecutionEnvironment;

public class FlinkFileTest {
	public static void main(String[] args) throws Exception {
	    ExecutionEnvironment env = ExecutionEnvironment.createLocalEnvironment();
	
	    DataSet<String> data = env.readTextFile("F:///path/to/file");
	    
	    data
	        .filter(new FilterFunction<String>() {
	            public boolean filter(String value) {
	                return value.startsWith("http://");
	            }
	        })
	        .writeAsText("F:///path/to/"+UUID.randomUUID());
	
	    JobExecutionResult res = env.execute();
	}
}

